#include<bits/stdc++.h>
using namespace std;
int ksm(int a , int b , int p){
	int ans = 1 % p;
	while(b){
		if(b & 1){
			ans = 1ll * ans * a % p;
		}
		a = 1ll * a * a % p;
		b >>= 1;
	}
	return ans;
} 
int main(){
	//freopen("pow.in" , "r" , stdin);
	//freopen("pow.out" , "w" , stdout);
	int a , b , p;
	cin >> a >> b >> p;
	int i = ksm(a , b , p);
	cout << i << endl;
	return 0;
}
